*** Replication .do file for Hunt and Fontana (2024), "Some Politics is Still Local: Voter Preferences for Local Candidates"


********************EXPERIMENT REPLICATION*************************
use "huntfontana_survey.dta"

* Weighting
replace weight = 1.718432511 if party_id == 1
replace weight = 0.560598247 if party_id == 2
replace weight = 1.144800777 if party_id == 3
replace weight = 0.437827715 if party_id == 4
replace weight = 1.28106152 if party_id == 5
replace weight = 0.7573474 if party_id == 6
replace weight = 2.654383736 if party_id == 7

*** Figure 1 - Predicted Change in Probability of Voting Demcorat Relative to Control
ta condition [w=weight], su(vote_dem_lean)
** Diff. of means/linear combination tests for statistical significance and 95% confidence intervals
svy: mean vote_dem_lean, over(local_dem) coeflegend
lincom _b[c.vote_dem_lean@1.local_dem] - _b[c.vote_dem_lean@0bn.local_dem]
svy: mean vote_dem_lean, over(local_rep) coeflegend
lincom _b[c.vote_dem_lean@1.local_rep] - _b[c.vote_dem_lean@0bn.local_rep]

*** Figure 2 - Democratic Candidate Evaluations
ta condition [w=weight], su(fav_dem)
ta condition [w=weight], su(trust_dem)
ta condition [w=weight], su(relate_dem)
** Diff. of means/linear combination tests for statistical significance and 95% confidence intervals
svy: mean fav_dem, over(local_dem) coeflegend
lincom _b[c.fav_dem@1.local_dem] - _b[c.fav_dem@0bn.local_dem]

svy: mean fav_dem, over(local_rep) coeflegend
lincom _b[c.fav_dem@1.local_rep] - _b[c.fav_dem@0bn.local_rep]

svy: mean trust_dem, over(local_dem) coeflegend
lincom _b[c.trust_dem@1.local_dem] - _b[c.trust_dem@0bn.local_dem]

svy: mean trust_dem, over(local_rep) coeflegend
lincom _b[c.trust_dem@1.local_rep] - _b[c.trust_dem@0bn.local_rep]

svy: mean relate_dem, over(local_dem) coeflegend
lincom _b[c.relate_dem@1.local_dem] - _b[c.relate_dem@0bn.local_dem]

svy: mean relate_dem, over(local_rep) coeflegend
lincom _b[c.relate_dem@1.local_rep] - _b[c.relate_dem@0bn.local_rep]

*** Figure 3 - Republican Candidate Evaluations
ta condition [w=weight], su(fav_rep)
ta condition [w=weight], su(trust_rep)
ta condition [w=weight], su(relate_rep)
** Diff. of means/linear combination tests for statistical significance and 95% confidence intervals
svy: mean fav_rep, over(local_rep) coeflegend
lincom _b[c.fav_rep@1.local_rep] - _b[c.fav_rep@0bn.local_rep]

svy: mean fav_rep, over(local_dem) coeflegend
lincom _b[c.fav_rep@1.local_dem] - _b[c.fav_rep@0bn.local_dem]

svy: mean trust_rep, over(local_rep) coeflegend
lincom _b[c.trust_rep@1.local_rep] - _b[c.trust_rep@0bn.local_rep]

svy: mean trust_rep, over(local_dem) coeflegend
lincom _b[c.trust_rep@1.local_dem] - _b[c.trust_rep@0bn.local_dem]

svy: mean relate_rep, over(local_rep) coeflegend
lincom _b[c.relate_rep@1.local_rep] - _b[c.relate_rep@0bn.local_rep]

svy: mean relate_rep, over(local_dem) coeflegend
lincom _b[c.relate_rep@1.local_dem] - _b[c.relate_rep@0bn.local_dem]

*** Appendix Table A1 - Experimental Effects Political Attitudes Toward Democratic Candidate
svy: logit vote_dem_lean local_dem_complete dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem local_dem_complete dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem local_dem_complete dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem local_dem_complete dem_party_id_num liberalism hispanic race_black female age educ_3

*** Appendix Table A2 - Coefficients for Heterogeneity Results: Interactions with Local Democrat Treatment
*Vote for Dem
svy: logit vote_dem_lean c.local_dem_complete##i.likely_vote_binary dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.independent dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.female dem_party_id_num liberalism hispanic race_black age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.race_black dem_party_id_num liberalism hispanic female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.hispanic dem_party_id_num liberalism race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##c.educ_3 dem_party_id_num liberalism hispanic race_black female age 
svy: logit vote_dem_lean c.local_dem_complete##i.urban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.rural dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.suburban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.blue_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.red_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: logit vote_dem_lean c.local_dem_complete##i.swing_state dem_party_id_num liberalism hispanic race_black female age educ_3
*Dem Favorability
svy: ologit fav_dem c.local_dem_complete##i.likely_vote_binary dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.independent dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit fav_dem c.local_dem_complete##i.female dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit fav_dem c.local_dem_complete##i.race_black dem_party_id_num liberalism hispanic female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.hispanic dem_party_id_num liberalism race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##c.educ_3 dem_party_id_num liberalism hispanic race_black female age 
svy: ologit fav_dem c.local_dem_complete##i.urban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.rural dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.suburban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.blue_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.red_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit fav_dem c.local_dem_complete##i.swing_state dem_party_id_num liberalism hispanic race_black female age educ_3
*Dem Trust
svy: ologit trust_dem c.local_dem_complete##i.likely_vote_binary dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.independent dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit trust_dem c.local_dem_complete##i.female dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit trust_dem c.local_dem_complete##i.race_black dem_party_id_num liberalism hispanic female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.hispanic dem_party_id_num liberalism race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##c.educ_3 dem_party_id_num liberalism hispanic race_black female age 
svy: ologit trust_dem c.local_dem_complete##i.urban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.rural dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.suburban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.blue_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.red_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit trust_dem c.local_dem_complete##i.swing_state dem_party_id_num liberalism hispanic race_black female age educ_3
*Dem Relate
svy: ologit relate_dem c.local_dem_complete##i.likely_vote_binary dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.independent dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit relate_dem c.local_dem_complete##i.female dem_party_id_num liberalism hispanic race_black age educ_3
svy: ologit relate_dem c.local_dem_complete##i.race_black dem_party_id_num liberalism hispanic female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.hispanic dem_party_id_num liberalism race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##c.educ_3 dem_party_id_num liberalism hispanic race_black female age 
svy: ologit relate_dem c.local_dem_complete##i.urban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.rural dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.suburban dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.blue_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.red_state dem_party_id_num liberalism hispanic race_black female age educ_3
svy: ologit relate_dem c.local_dem_complete##i.swing_state dem_party_id_num liberalism hispanic race_black female age educ_3

*** Table 1 - 
*Favorability (subtract Control mean from Local Candidate Treatment mean, divide by Control mean for % increase)
ta local_dem if party_id_3 == "Democrat", su(fav_dem)
ta local_dem if party_id_3 == "Republican", su(fav_dem)
ta local_dem if party_id_3 == "Independent", su(fav_dem)
ta local_rep if party_id_3 == "Democrat", su(fav_rep)
ta local_rep if party_id_3 == "Republican", su(fav_rep)
ta local_rep if party_id_3 == "Independent", su(fav_rep)

*Relatability (subtract Control mean from Local Candidate Treatment mean, divide by Control mean for % increase)
ta local_dem if party_id_3 == "Democrat", su(relate_dem)
ta local_dem if party_id_3 == "Republican", su(relate_dem)
ta local_dem if party_id_3 == "Independent", su(relate_dem)
ta local_rep if party_id_3 == "Democrat", su(relate_rep)
ta local_rep if party_id_3 == "Republican", su(relate_rep)
ta local_rep if party_id_3 == "Independent", su(relate_rep)

*Trust (subtract Control mean from Local Candidate Treatment mean, divide by Control mean for % increase)
ta local_dem if party_id_3 == "Democrat", su(trust_dem)
ta local_dem if party_id_3 == "Republican", su(trust_dem)
ta local_dem if party_id_3 == "Independent", su(trust_dem)
ta local_rep if party_id_3 == "Democrat", su(trust_rep)
ta local_rep if party_id_3 == "Republican", su(trust_rep)
ta local_rep if party_id_3 == "Independent", su(trust_rep)

*Vote Choice (subtract Control mean from Local Candidate Treatment mean)
ta local_dem if party_id_3 == "Democrat", su(vote_dem_lean)
ta local_dem if party_id_3 == "Republican", su(vote_dem_lean)
ta local_dem if party_id_3 == "Independent", su(vote_dem_lean)
ta local_rep if party_id_3 == "Democrat", su(vote_rep_lean)
ta local_rep if party_id_3 == "Republican", su(vote_rep_lean)
ta local_rep if party_id_3 == "Independent", su(vote_rep_lean)





********************OBSERVATIONAL REPLICATION*************************

*** Figure 4 - Percentage of Senate incumbents with select local ties
use "huntfontana_incumbents.dta"
ta born_instate 
ta hs_instate
ta undergrad_instate
ta postgrad_instate

*** Table 2 - Incumbent Electoral Conditions Based on Local Roots Index Score, 1960-2020
use "huntfontana_incumbents.dta"
ta roots_index
ta roots_index, su(unopposed)
ta roots_index, su(incumbent_pct_2p_stwd_sen)
ta roots_index, su(pol_exp_any)

*** Table 3 - Effects on Democratic Vote Share, Open-Seat Senate Candidates (1960-2020)
use "huntfontana_openseats.dta"
reg dem_cand_vote_pct dem_born_instate rep_born_instate cand_pres_pct_2p national_partisan2p dem_pol_exp_any rep_pol_exp_any dem_educ_postgrad rep_educ_postgrad dem_nonwhite rep_nonwhite dem_female rep_female total_pop_log land_area_log if democrat == 1

*** Table 4 - Effects on Two-Party Vote Share, Senate Incumbents (1960-2020)
use "huntfontana_incumbents.dta"
xtset senator_group
xtreg incumbent_pct_2p_stwd_sen roots_index inc_pres_pct national_partisan2p ch_quality terms_served chamber_leader cmte_chair scandal land_area_log total_pop_log time_60s if unopposed == 0,
margins, at(roots_index=(0(1)4))

*** Appendix Table A3 - Effects on Likelihood of Running Unopposed; Senate Incumbents, 1960-2020
use "huntfontana_incumbents.dta"
xtset senator_group
melogit unopposed roots_index inc_pres_pct national_partisan2p terms_served chamber_leader cmte_chair land_area_log total_pop_log time_60s || senator_group:
margins, at(roots_index=(0(1)4)) predict(mu fixedonly) vsquish 

*** Figure 6 - Two-party vote share advantage for locally-born candidates across decades (2010s includes 2020 election)
*Incumbents (subtract born in-state averages from born out-of-state averages)
use "huntfontana_incumbents.dta"
ta decade if born_instate == 0, su(incumbent_pct_2p_stwd_sen)
ta decade if born_instate == 1, su(incumbent_pct_2p_stwd_sen)
*Open Seats (subtract born in-state averages from born out-of-state averages)
use "huntfontana_openseats.dta"
ta decade if born_instate == 0, su(cand_vote_pct)
ta decade if born_instate == 1, su(cand_vote_pct)

*** Appendix Table A4 - Effects on Two-Party Vote Share, Senate Incumbents (1960-2020)
use "huntfontana_incumbents.dta"
xtreg incumbent_pct_2p_stwd_sen born_instate inc_pres_pct national_partisan2p ch_quality terms_served chamber_leader cmte_chair scandal land_area_log total_pop_log time_60s if unopposed == 0
xtreg incumbent_pct_2p_stwd_sen hs_instate inc_pres_pct national_partisan2p ch_quality terms_served chamber_leader cmte_chair scandal land_area_log total_pop_log time_60s if unopposed == 0
xtreg incumbent_pct_2p_stwd_sen undergrad_instate inc_pres_pct national_partisan2p ch_quality terms_served chamber_leader cmte_chair scandal land_area_log total_pop_log time_60s if unopposed == 0
xtreg incumbent_pct_2p_stwd_sen postgrad_instate inc_pres_pct national_partisan2p ch_quality terms_served chamber_leader cmte_chair scandal land_area_log total_pop_log time_60s if unopposed == 0

*** Appendix Table A5 - Effects on Democratic Vote Share, "Sacrificial Lamb" Open-Seat Senate Candidates (1960-2020)
use "huntfontana_openseats.dta"
reg dem_cand_vote_pct dem_born_instate rep_born_instate national_partisan2p dem_pol_exp_any rep_pol_exp_any dem_educ_postgrad rep_educ_postgrad dem_nonwhite rep_nonwhite dem_female rep_female total_pop_log land_area_log if democrat == 1 & cand_pres_pct_2p < 40
reg dem_cand_vote_pct dem_born_instate rep_born_instate cand_pres_pct_2p national_partisan2p dem_pol_exp_any dem_educ_postgrad rep_educ_postgrad dem_nonwhite rep_nonwhite dem_female rep_female total_pop_log land_area_log if democrat == 1 & dem_pol_exp_any == 0
